Field of the Invention
The invention relates in general to subtitles, and more particularly to a subtitle processing device and associated method and a subtitle parsing method.
Description of the Related Art
Subtitles may be categorized into embedded subtitles and plug-in subtitles. Embedded subtitles are a part of a video file. For example, a video file may include a video section, an audio section and a subtitle section. Such subtitle section cannot be directly accessed by general users. Plug-in subtitles are a file independent from the video file, and can be directly edited by users. For example, users may adjust the time or texts of the plug-in subtitles. There are various formats for plug-in subtitle files, e.g., “.srt”, “.smi”, “.sub” and “.txt” are some common file extensions of subtitle files. According to different formats, one plug-in subtitle file may include one set or multiple sets of subtitles. One set of subtitles represent a set of complete subtitles of a video. For example, Japanese subtitles, Traditional Chinese subtitles or Simplified Chinese subtitles are individually one set of subtitles. Each subtitle unit of one set of subtitles usually includes a starting time, an ending time and subtitle contents, or associated variations. FIG. 1A shows a schematic diagram of contents of a conventional subtitle file in an “.srt” format. The subtitle file at least includes a subtitle unit 110 and a subtitle unit 120, which respectively includes starting times 112 and 122, ending times 114 and 124, and subtitle contents 116 and 126. When a current playback time of a video reaches the starting time, the corresponding subtitle contents are displayed on a screen; when the current playback time of the video reaches the ending time, the corresponding subtitle contents are cleared from the screen. FIG. 1B shows a schematic diagram of a conventional subtitle file in a “.sub” format. The subtitle file at least includes a subtitle unit 130 and a subtitle unit 140, which respectively include starting time 132 and 142, ending time 134 and 144, and subtitle contents 136 and 146. It should be noted that, the starting time and the ending time are not directly displayed by hour, minute and second, and need to be converted. A basic column 150 records a conversion method. In this example, 25 frames represent 1 second. Thus, the subtitle contents 136 are in fact displayed from the 1st second to the 2nd second, and so forth.
FIG. 2 shows a diagram of configuration of a conventional memory for processing subtitles. A memory 200 is disposed in a playback device, and is for parsing and displaying subtitles. The memory 200 includes a subtitle section 210 and an index section 220. In general, the playback device supports a fixed number of sets of subtitles. Four sets of subtitles are used here as an example. The subtitle contents of these four sets of subtitles are respectively temporarily stored in subtitle sub-sections 212, 214, 216 and 218. The four sets of subtitles have respective corresponding indices respectively stored in index sub-sections 222, 224, 226 and 228. A temporary storage sub-section 211 is for temporarily storing a subtitle unit to be parsed when the playback device parses the subtitle file. Details of purposes of the memory sections are given with reference to a flowchart of processing subtitles. FIG. 3 shows a flowchart of a conventional subtitle parsing method. Before a video is played, a controller (e.g., a microprocessor or a central processing unit (CPU)) of a playback device parses multiple sets of subtitles. During the parsing process, a part of the subtitle file is first temporarily stored in the temporary storage sub-section 211 of the memory 200, parsed subtitle contents of the part of the subtitle file are stored in one of the subtitle sub-sections 212, 214, 216 and 218, and an index is established and stored in the corresponding index sub-section. When the video is later played, the corresponding subtitles are identified from the memory according to the subtitles the user selects and then displayed. More specifically, one of the four sets of subtitle files are obtained from a storage medium (e.g., a flash memory, a hard drive or a solid-state hard drive) at the beginning of a subtitle process procedure (step S310). As the procedure is at an initial phase, the temporary storage sub-section 211 does not contain any data, and so step S320 and step S330 do not have any contents to be recorded. Thus, the subtitle processing procedure omits these two steps and performs step S340. At this point, it is discovered that the temporary storage sub-section 211 does not contain any data, and so step S360 is performed to determine whether the entire subtitle file is already parsed. Because the subtitle file is only starting to be read, a determination result of step S360 is negative and the procedure proceeds to step S370. In step S370, a part of the contents of the subtitle file is read from the memory medium to the temporary storage sub-section 211. In most circumstances, as the size of each subtitle file is greater than that of the temporary storage sub-section 211, one subtitle file needs to be read for a multiple number of times before it can be fully parsed. The subtitle unit then is identified from the temporary storage sub-section 211 (step S350). If the subtitle unit is identified, the subtitle contents of the subtitle unit are stored in the subtitle sub-section 212 (step S320), and the starting time and ending time of the subtitle unit as well as the position of the subtitle unit in the memory 200 in the last step are recorded in the index sub-section 222 (step S330), thus completing parsing one subtitle unit. When the data in the temporary storage sub-section 211 is not yet fully processed (step 340), a next subtitle unit is identified (step S350) until the data in the temporary storage sub-section 211 is fully processed. It is then determined whether the current subtitle file is completely parsed (step S360). If so, it means that the current subtitle file is completely parsed; if not, step S370 is iterated to read another part of the contents of the subtitle file from the memory medium to the temporary storage sub-section 211. Having completed parsing the current subtitle file, the above process is repeated to parse the other three subtitle files, and the data obtained from parsing is filled into the subtitle sub-sections 214, 216 and 218 as well as the index sub-sections 224, 226 and 228.
FIG. 4 shows a flowchart of a conventional method for searching for subtitles when playing a video. After starting to play the video, the corresponding index sub-section (e.g., the index sub-section 224) is identified according to the selected subtitles (step S410), the position of the subtitle contents to be displayed in the subtitle sub-section 214 is identified from the index according to the current playback time (step S420), the subtitle contents are read and a playback interface is notified to play the read subtitle contents (step S430), and it is determined whether the video is completely played (step S440). The process ends when the video is completely played, or else contents of next subtitle contents to be displayed are search for.
In conclusion, the memory 200 is an exclusive memory used for displaying subtitles, and has a fixed size that is determined at the time of completing the system and cannot be readily expanded, meaning that the number of sets of subtitles supported cannot be easily increased by later increasing the memory. Thus, the above conventional memory configuration and processing method for subtitles only allow a playback device to support a fixed number of sets of subtitles (e.g., four sets in the above example). Further, in the conventional method, all subtitle contents of one set of subtitles are temporarily stored in the subtitle sub-section, and so one subtitle sub-section usually needs 256 KB or more storage space. Further, information of index table is quite complicated (including the starting time and the ending time of each subtitle unit as well as the position of the subtitle contents in the memory). Therefore, one index sub-section usually needs to occupy 128 KB or more storage space, and about 1.5 MB or more storage space is required to support four sets of subtitles. In addition, the conventional solution stores all of the multiple sets of subtitles supported in different subtitle subsections, and the memory space occupied by three of the four sets of subtitles is equivalently wasted if only one of the four sets of subtitles are used in the playback process. Such issue of waste is aggravated when the number of sets of subtitles supported gets larger.